<?php session_start(); /*Craft o load the session and load session vars*/ ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf8" />
	<title>Save a tree</title>
	<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<div style="padding: 100px 0 0 250px;">
	<div class="login-box">
		<?php 
			include ('gvar.php');
			$code=$_GET['code'];

			$query = 'SELECT Password FROM Files WHERE Code="'.$code.'"';
			$consulta = mysql_query ($query, $dbc) or die ("ERROR 500: Internal error in the server (Unable to check the user)");
			$nfilas = mysql_num_rows ($consulta);

			if ($nfilas == 1) {
				while($row = mysql_fetch_array($consulta)){
					$pass = $row["Password"];
					echo '<form method="POST" action="#">
							 Password: <br /><input type="password" name="passwordChecked" /><br />
							 <input type="submit" class="button" value="Confirmar" />
						  </form>
						  <input style="margin-left:90px;" type="button" class="button" value="Enrere" onclick="location.href=\'index.php\'">';
					if (isset($_POST['passwordChecked'])){
						if ($pass == $_POST['passwordChecked']) {
							echo "Password correcto";
							echo '<a href="uploads/screenshot_12172012_183054.png">Descarrega</a>';
						} else {
							echo "Password incorrecto";
						}
					} else "Error"; 
					//print ("<META HTTP-EQUIV='refresh' content='1;URL=index.php'>");	
				}
			}
		?>
	</div>
</div>
</body>
</html>